<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>采购退货订单出库确认</title>
  </head>
  <body>
    <script type="text/javascript">
      Ext.onReady(function(){
        var purchaseReturnedId = Ext.create('Ext.form.field.Hidden', {
          name: 'purchase_returned_id',
          value: '<%=params[:id]%>'
        });

        var warehouse =  Ext.create('Ext.form.ComboBox', {
          fieldLabel: '退货出库仓库',
          store: warehouseStore,
          valueField: 'id',
          displayField: 'name',
          name: 'warehouse_id',          
          loadingText: '搜索中...',
          width:140,
          allowBlank: false,
          //pageSize: 10,
          minChars: 0,
          editable:false
        });

        //实际退货日期
        var actionDate = Ext.create('Ext.form.field.Date', {
          fieldLabel: '出库日期',
          allowBlank: false,
          name: 'action_date',
          format: 'Y-m-d', //格式化日期
          //disabledDays: [0,6],	//不让选择周六，周日
          //disabledDaysText: "周末要休息",
          invalidText: "您输入的日期格式不对，正确格式为2010-01-18",
          blankText: "出库日期必须选择",
          emptyText: '出库日期...'
          //anchor: '50%'
        });
        
        //提交按钮
        var deliveryConfirmButton = Ext.create('Ext.Button', {
          text: '提交',
          iconCls: 'icon-save',
          handler: function(){
            deliveryConfirmButton.setDisabled(true);
            if (returnedDeliveryConfirmFormPanel.form.isValid()) {
              returnedDeliveryConfirmFormPanel.form.submit({
                success: function(result, resp){
                  if (resp.result.info.indexOf("成功") >= 0) {
                    returnedDeliveryWin.destroy();
                  } else {
                    Ext.MessageBox.show({
                      title: '消息',
                      msg: resp.result.info,
                      buttons: Ext.MessageBox.OK,
                      icon: Ext.MessageBox.WARNING
                    });                    
                  }
                  deliveryConfirmButton.enable();
                },
                failure: function(result, request){
                  deliveryConfirmButton.enable();
                  Ext.MessageBox.show({
                    title: '消息',
                    msg: "通讯失败，请从新操作",
                    buttons: Ext.MessageBox.OK,
                    icon: Ext.MessageBox.WARNING
                  });
                }
              });
            }
            else {
              deliveryConfirmButton.enable();
              
            }
          }
        })


        var closeButton = Ext.create('Ext.Button', {
          text: '关闭',
          tooltip: '关闭当前窗口，并且当前编辑的信息不能保存。',
          iconCls: 'exit',
          handler: function(){
            returnedDeliveryWin.destroy();
          }
        });
        
        var returnedDeliveryConfirmFormPanel = Ext.create('Ext.form.Panel', {
          fieldDefaults: {
            labelWidth: 80,
            labelAlign: 'right'
          },
          width: '290',
          frame : true,
          url: '/purchase_returned/deliveryFinish',
          method: 'GET',
          items: [purchaseReturnedId,warehouse,actionDate],
          buttons: [deliveryConfirmButton,closeButton]
        });
        returnedDeliveryConfirmFormPanel.render('purchase_returned_confirm_form');
      })
    </script>
    <div id="purchase_returned_confirm_form"></div>
  </body>
</html>
